package com.dcxs.shop.module.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dcxs.shop.common.exception.RRException;
import com.dcxs.shop.module.user.entity.JsUsr;
import com.dcxs.shop.module.user.mapper.JsUsrMapper;
import com.dcxs.shop.module.user.service.IJsUsrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2020-02-22
 */
@Service
public class JsUsrServiceImpl extends ServiceImpl<JsUsrMapper, JsUsr> implements IJsUsrService {

    @Autowired
    private IJsUsrService usrService;

    @Override
    public Integer getUserIdByPhone(String phone) {
        JsUsr usr = usrService.getOne(new QueryWrapper<JsUsr>().eq("phone",phone));
        if(null==usr){
            throw new RRException("没有此人");
        }
        return usr.getId();
    }
}
